name_filter :append_runtime_dependent do |names, configurations, options|
  prev_snap ||= options(:area).current_snapshot
  next names unless prev_snap

  getter = lambda do |name|
    dep = prev_snap.find_deployment_by_name(name)
    dep.runtime_dependencies
  end

  deps_resolver = Wondercap::DependencyResolver.new(getter)
  deps_resolver.add_dependent(names, prev_snap.deployments.map { |dep| dep.name })
end

name_filter :append_runtime_required do |names, configurations, options|
  getter = lambda do |name|
    logger.debug "getting required deps for #{name}"
    return nil unless configuration_defined? name

    configurations[name].runtime_dependencies
  end
  
  Wondercap::DependencyResolver.new(getter).add_required(names).to_a
end

name_filter :order_by_runtime_dependencies do |names, configurations, options|
  getter = lambda do |name|
    logger.debug "getting required deps for #{name}"
    return nil unless configurations[name]

    configurations[name].runtime_dependencies
  end
  
  Wondercap::DependencyResolver.new(getter).order_by_dependencies(names).to_a
end
